Central Article

Creating a Two-Way Video Chat Application in Macromedia Central


Table of Contents

  1. Introduction
  2. The vChat Application
  3. The Client Side: Building the Application
  4. The Client Side: Building the Pod
  5. Lessons Learned

The Client Side: Building the Application

The vChat application is nothing but a help page and a pod launcher, so it's possibly the easiest Central application you'll ever build.

Open Flash MX or Flash MX 2004 and create a new document, with a Stage size of 500 x 400 pixels. Use all the assets you need to make it look the way you want and add an Open vChat text field, with an Icon Button component next to it (get the component from the Central Components panel). Call the Icon Button component fShowPod and, in the parameters, choose icon_toss-to from the Built-In Icon menu.

Save the file as app.fla in a folder of your choice.

Because I like to keep my ActionScript code in a separate file, I created an app.as file right next to the app.fla I just created, and added #include "app.as" in the first frame of my movie's Timeline. You could also just paste the following code in the first frame within the FLA.

Either way, here's the whole ActionScript code:

//Central Methods
function getMinimumSize() { 
   return {width:500, height:400};
}
function getMaximumSize() {
   return {width: 500, height:400};
}
onActivate = function(shell, appId, shellId, baseTabIndex, appData) { 
   gShell = shell;
}
//Icon Button Handler
fShowPod.onRelease = function()
{
   var shownPods = gShell.getViewedPods();
   if (shownPods.length == 0) {
      var pods = gShell.getPods();
      gShell.viewPod(pods[0].id);
   }
}
// let the Central shell know we're loaded
// the shell will call us back soon with an onActivate
Central.initApplication(this, this);

stop(); 

All this code does is tell Central that the application is 500 pixels wide and 400 pixels high, and that it shouldn't resize. You define an onActivate method to save a reference of the Central shell in a gShell global variable. You use this reference in the fShowPod.onRelease function, which shows a pod only if the pod for this application doesn't already appear.

The last bit of Central magic you need to do is tell Central that you're alive by calling Central.initApplication.

That's all for this vChat application. As I said, it's very basic. Feel free to expand it at will.